package com.qeado.content.service.impl;

import java.util.List;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.qeado.content.dao.NewsPublishManageDao;
import com.qeado.content.model.NewsPublish;
import com.qeado.content.service.NewsPublishManageService;

@Service
public class NewsPublishManageServiceImpl implements NewsPublishManageService {
	@Autowired
	private NewsPublishManageDao newsPublishManageDao;

	@Override
	public void deleteNews(String id) {
		newsPublishManageDao.deleteNews(id);
	}

	@Override
	public List<NewsPublish> getNewsSortList() {
		return newsPublishManageDao.getNewsSortList();
	}

	@Override
	public List<NewsPublish> newsPublishSearch(NewsPublish news) {
		return newsPublishManageDao.newsPublishSearch(news);
	}

	@Override
	public String saveNews(NewsPublish news) {
		if(news.getId() == null || "".equals(news.getId())) {
			news.setId(UUID.randomUUID().toString());
			newsPublishManageDao.insertNews(news);
		} else {
			newsPublishManageDao.updateNews(news);
		}
		return null;
	}

	@Override
	public NewsPublish searchNewsPublishById(String id) {
		return newsPublishManageDao.searchNewsPublishById(id);
	}

}
